﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wise.Entities;

namespace NHI.Sync.Tools.Forms
{
    /// <summary>
    /// MapConfig.xaml 的交互逻辑
    /// </summary>
    public partial class Form_MapConfig : UserControl
    {
        public static List<string> SourceTables = new List<string>();

        public Form_MapConfig()
        {
            InitializeComponent();
        }

        public async void LoadData()
        {
            await Task.Run(()=>InitData());
        }

        /// <summary>
        /// 初始化数据
        /// </summary>
        public void InitData()
        {
            if (MyDbConfig.Current.表映射.Count>0)
                return;
            MyDbConfig.Current.InitMapping();
            Data = MyDbConfig.Current.表映射;
            this.Dispatcher.Invoke(() => {
                this.dataGrid1.DataContext = Data;
            });
        }

        List<表映射> Data = null;

        void ShowError(string msg)
        {
            MainWindow.Current.ShowError(msg);
        }


        public void OnPrevious_Click(object o, EventArgs e)
        {
            MainWindow.Current.tab_2.IsEnabled = true;
            MainWindow.Current.tab_2.IsSelected = true;
        }

        public void OnNext_Click(object o, EventArgs e)
        {
            MainWindow.Current.tab_4.IsEnabled = true;
            MainWindow.Current.tab_4.IsSelected = true;
        }

        private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if(this.dataGrid1.SelectedIndex==-1)
            {
                return;
            }

        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {

        }

        private void OnSplit_Click(object sender, RoutedEventArgs e)
        {

        }

        private void OnMerge_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
